package zhihui.mobile.ui;

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.View;

import com.zgm.utils.UiUtils;

import zhihui.mobile.manager.user.UserManager;
import zhihui.mobile.ui.login.LoginActivity;

/**
 * Created by 张公铭 on 2017/7/6 0006.
 * 需要权限的事件需继承该类
 */

public abstract class MyOnClickListener implements View.OnClickListener
{
    private Context mContext;

    public MyOnClickListener(Context context)
    {
        mContext = context;
    }

    @Override
    public void onClick(View v)
    {
        if (UserManager.getInstance().getCurUser() == null)
        {
            UiUtils.showDialog(mContext, "提示", "请登录！", "立即登录", new DialogInterface.OnClickListener()
            {
                @Override
                public void onClick(DialogInterface dialog, int which)
                {
                    Intent intent = new Intent(mContext, LoginActivity.class);
                    mContext.startActivity(intent);
                    dialog.dismiss();
                    dialog.cancel();
                    dialog = null;
                }
            }, "取消", new DialogInterface.OnClickListener()
            {
                @Override
                public void onClick(DialogInterface dialog, int which)
                {
                    dialog.dismiss();
                    dialog.cancel();
                    dialog = null;
                }
            });
            return;
        }
    }
}
